package com.yjhb.android.sbz.mvp.my;

import com.yjhb.android.sbz.entity.AdBanner;
import com.yjhb.android.sbz.entity.ResultSet;
import com.yjhb.android.sbz.http.HttpObserver;
import com.yjhb.android.sbz.http.HttpTool;
import com.yjhb.android.sbz.mvp.ConventionPresenter;

/**
 * 创建者 zx
 * 创建时间 2020/12/31 14:15
 */
public class MyPresenter extends ConventionPresenter<MyView> {
    private final String TAG = "MyPresenter";

    @Override
    protected void onDestroy() {

    }

    public MyPresenter(MyView objectCommonView) {
        super(objectCommonView);
    }

    public void getCustomerService(){
        if (view!=null){
            view.onWait("正在加载...");
        }
        HttpTool.request(model.addSingleFriend(null), new HttpObserver<String>() {
            @Override
            public void onResult(String data) {
                if (view!=null){
                    view.onCustomerService(data);
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view!=null){
                    view.onFailure(code, msg);
                }
            }
        });
    }

    /**
     * 广告
     */
    public void getBanner() {
        HttpTool.request(model.getBanner(1,10, 1), new HttpObserver<ResultSet<AdBanner>>() {
            @Override
            public void onResult(ResultSet<AdBanner> data) {
                if (view != null) {
                    view.onBanner(data.getRecords());
                }
            }

            @Override
            public void onError(int code, String msg) {

            }
        });
    }
}
